package com.cxcs.cxcsojbackendjudgeservice.judge.service.strategy;

import com.cxcs.cxcsojbackendmodel.dto.questionsubmit.JudgeInfo;
import org.springframework.stereotype.Service;

/**
 * 判题策略 调用管理 (在此调用策略匹配)
 *    对不同的编程语言 调用不同的策略strategy
 *
 * @Author: CxCS
 * @Version: 1.0
 * @Date: 2024-08
 */
@Service
public class JudgeManager {
    /**
     *  判题策略 执行管理
     * @param judgeContext
     * @return
     */
    public JudgeInfo doJudge(JudgeContext judgeContext) {
        JudgeStrategy judgeStrategy = new DefaulJudgeStrategy(); // 默认策略
        // 使用 Java判题策略（后续可以新增其他策略）
        if(judgeContext.getQuestionSubmit().getLanguage().equals("java")) {
            judgeStrategy = new JavaLanguageJudgeStrategy();
        }
        return judgeStrategy.doJudge(judgeContext);
    }
}
